package com.rslai.base.tool.servertest.database.postgresql;

import java.sql.PreparedStatement;
import java.sql.SQLException;

import org.dbunit.dataset.datatype.AbstractDataType;
import org.dbunit.dataset.datatype.StringDataType;
import org.dbunit.dataset.datatype.TypeCastException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LTreeDataType extends AbstractDataType {
    private static final Logger logger = LoggerFactory.getLogger(StringDataType.class);

    public LTreeDataType() {
        super("ltree", 1111, LTree.class, false);
    }

    public LTreeDataType(String name, int sqlType, Class classType, boolean isNumber) {
        super(name, sqlType, classType, isNumber);
    }

    public Object typeCast(Object value) throws TypeCastException {
        return null;
    }

    public void setSqlValue(Object value, int column, PreparedStatement statement) throws SQLException, TypeCastException {
        if (logger.isDebugEnabled()) {
            logger.debug("setSqlValue(value={}, column={}, statement={}) - start", new Object[]{value, new Integer(column), statement});
        }
        statement.setObject(column, new LTree(value));
    }
}
